﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Runtime.Serialization;

namespace DataLayer
{
    [KnownType(typeof(Movie))]
    [DataContract(IsReference=true)]
    public class ScreenCast
    {
        private DateTime _dateTime;
        private int _price;
        private Movie _movie;
        private MovieHall _movieHall;

        public ScreenCast(DateTime dateTime, int priceFactor, Movie movie, MovieHall movieHall)
        {
            SetValues(dateTime, priceFactor, movie, movieHall);
        }

        public ScreenCast(DateTime dateTime, int priceFactor, Movie movie)
        {
            SetValues(dateTime, priceFactor, movie, null);
        }

        public ScreenCast(DateTime dateTime, int priceFactor)
        {
            SetValues(dateTime, priceFactor, null, null);
        }

        public ScreenCast(DateTime dateTime)
        {
            SetValues(dateTime, 0, null, null);
        }

        public ScreenCast()
        {
            SetValues(new DateTime(), 0, null, null);
        }

        private void SetValues(DateTime dateTime, int priceFactor, Movie movie, MovieHall movieHall) {
            _dateTime = dateTime;
            _price = priceFactor;
            _movie = movie;
            _movieHall = movieHall;
        }

        [DataMember]
        public DateTime DateTime
        {
            get { return _dateTime; }
            set { _dateTime = value; }
        }

        [DataMember]
        public int Price
        {
            get { return _price; }
            set { _price = value; }
        }

        [DataMember]
        public Movie Movie
        {
            get { return _movie; }
            set { _movie = value; }
        }

        [DataMember]
        public MovieHall MovieHall
        {
            get { return _movieHall; }
            set { _movieHall = value; }
        }

        public override string ToString()
        {
            return Movie.Title + "\t\tPris: " + Price + Movie.Price + "\t\t Dato:" + DateTime;
        }
    }
}
